package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.IUserDAO;
import com.ecommerce.dal.entity.User;
import com.ecommerce.dal.service.IUserManagerService;

@Service("userManagerService")
public class UserManagerService implements IUserManagerService {

	@Autowired
	private IUserDAO userDAO;

	@Override
	public User retrieveUser(long userId) {
		return userDAO.findByUserId(userId);
	}

	@Override
	public User retrieveUser(String username) {
		return userDAO.findByUserUsername(username);
	}

	@Override
	public User retrieveUser(String username, String password) {
		// TODO Auto-generated method stub
		return userDAO.findByUserVerified(username, password);
	}

	@Override
	public boolean checkUserIfExists(String userName) {
		return userDAO.checkUserNameIfExists(userName);
	}

	@Override
	public boolean checkUserIfExists(long userId) {
		// TODO Auto-generated method stub
		return userDAO.checkUserIdIfExists(userId);
	}

	@Override
	public void saveUser(User user) {
		userDAO.save(user);
	}

	@Override
	public List<User> retrieveAllUsers() {
		return userDAO.findAllUsers();
	}

	@Override
	public List<User> retrieveNewsletterUsers() {

		return userDAO.findNewsletterUsers();

	}

	

	// @Override
	// public void save(User user) {
	// userDAO.save(user);
	// }

	@Override
	public void updateUser(User user) {
		userDAO.update(user);
	}

	@Override
	public void deleteUser(User user) {
		userDAO.delete(user);
	}

	
	// @Override
	// public User findByUserId(long userId) {
	// return userDAO.findByUserId(userId);
	// }
	//
	// @Override
	// public User findByUserUsername(String username) {
	// // TODO Auto-generated method stub
	// return userDAO.findByUserUsername(username);
	// }
	//
	// @Override
	// public User findByUserVerified(String username, String password) {
	// // TODO Auto-generated method stub
	// return userDAO.findByUserVerified(username, password);
	// }

}
